package com.thinta.wind.ui.home.fragment

import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.lifecycle.ViewModelProvider

import com.thinta.wind.R
import com.thinta.wind.base.BaseFragment
import com.thinta.wind.base.BaseModel
import com.thinta.wind.base.ViewModelFactory
import com.thinta.wind.databinding.HotFragmentBinding
import com.thinta.wind.ui.home.HomePageAdapter
import kotlinx.android.synthetic.main.hot_fragment.*

class HotFragment : BaseFragment<BaseModel, HotFragmentBinding>() {

    private val tabList = listOf("附近","榜单","明星","搞笑","测试")

    private val tabFragment = listOf(
        NearByFragment(), ListFragment(), StarFragment(), FunnyFragment(), TestFragment()
    )

    companion object {
        fun newInstance() = HotFragment()
    }

    override fun getModelFactory(): ViewModelProvider.NewInstanceFactory = ViewModelFactory()

    override fun viewModelClass(): Class<BaseModel> = BaseModel::class.java

    override fun getLayoutId(): Int = R.layout.hot_fragment

    override fun afterCreate() {
        setTab()
    }

    private fun setTab(){
        dataBinding?.hotPager?.adapter = HomePageAdapter(tabFragment, tabList, parentFragmentManager, FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT)
        dataBinding?.tabLayout?.setupWithViewPager(hot_pager)
    }

}
